#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>


#define CLI_PORT 8008
#define MAXLINE 80
int main(){
    //socket
    int cfd=socket(AF_INET,SOCK_STREAM,0);
    //connect
    struct sockaddr_in cliaddr;
    cliaddr.sin_family=AF_INET;
    cliaddr.sin_port=htons(CLI_PORT);
    inet_pton(AF_INET,"192.168.0.8",&cliaddr.sin_addr);
    
    int cn=connect(cfd,(struct sockaddr*) &cliaddr,sizeof(cliaddr));
    char buf[MAXLINE];
    
    while(1){
        int n=read(cfd,buf,sizeof(buf));
        write(STDOUT_FILENO,buf,n);
        n=read(STDIN_FILENO,buf,sizeof(buf));
        write(cfd,buf,n);
    } 
    close(cfd);
    return 0;
}

